package com.ace.model.bo;

/***********************************************************************
 * Module:  Agence.java
 * Author:  a.kanwar
 * Purpose: Defines the Class Agence
 ***********************************************************************/

import java.util.*;

public class Agence {
   
    /********************************************************
     * attribute
     *******************************************************/
    
    private int idAgence;
    private java.lang.String libelle, adresse;
    private int codePostal;
    private java.lang.String ville;
    private java.util.Collection<Assure> assure;
    private java.util.Collection<Agent> agent;
    private Responsable responsable;

    
    /***********************************************
     * Constructor 
     ***********************************************/
    
    public Agence(int idAgence, String libelle, String adresse, int codePostal, String ville, Collection<Assure> assure, Collection<Agent> agent, Responsable responsable) {
        this.idAgence = idAgence;
        this.libelle = libelle;
        this.adresse = adresse;
        this.codePostal = codePostal;
        this.ville = ville;
        this.assure = assure;
        this.agent = agent;
        this.responsable = responsable;
    }

    public Agence(String libelle, String adresse, int codePostal, String ville, Collection<Assure> assure, Collection<Agent> agent, Responsable responsable) {
        this.libelle = libelle;
        this.adresse = adresse;
        this.codePostal = codePostal;
        this.ville = ville;
        this.assure = assure;
        this.agent = agent;
        this.responsable = responsable;
    }

    
    /**************************************
     * Getter and setter
     *  
     **************************************/
    
    public int getIdAgence() {
        return idAgence;
    }

    public void setIdAgence(int idAgence) {
        this.idAgence = idAgence;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public String getAdresse() {
        return adresse;
    }

    public void setAdresse(String adresse) {
        this.adresse = adresse;
    }

    public int getCodePostal() {
        return codePostal;
    }

    public void setCodePostal(int codePostal) {
        this.codePostal = codePostal;
    }

    public String getVille() {
        return ville;
    }

    public void setVille(String ville) {
        this.ville = ville;
    }

    
    @Override
    public String toString() {
        return "Agence{" + "idAgence=" + idAgence + ", libelle=" + libelle + ", adresse=" + adresse + ", codePostal=" + codePostal + ", ville=" + ville + ", assure=" + assure + ", agent=" + agent + ", responsable=" + responsable + '}';
    }
    
    
   
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    /******************************************************
     * generate code by power ACM
     ******************************************************/
    
    
    
   
   /** @pdGenerated default getter */
   public java.util.Collection<Assure> getAssure() {
      if (assure == null)
         assure = new java.util.HashSet<Assure>();
      return assure;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorAssure() {
      if (assure == null)
         assure = new java.util.HashSet<Assure>();
      return assure.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newAssure */
   public void setAssure(java.util.Collection<Assure> newAssure) {
      removeAllAssure();
      for (java.util.Iterator iter = newAssure.iterator(); iter.hasNext();)
         addAssure((Assure)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newAssure */
   public void addAssure(Assure newAssure) {
      if (newAssure == null)
         return;
      if (this.assure == null)
         this.assure = new java.util.HashSet<Assure>();
      if (!this.assure.contains(newAssure))
      {
         this.assure.add(newAssure);
         newAssure.setAgence(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldAssure */
   public void removeAssure(Assure oldAssure) {
      if (oldAssure == null)
         return;
      if (this.assure != null)
         if (this.assure.contains(oldAssure))
         {
            this.assure.remove(oldAssure);
            oldAssure.setAgence((Agence)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllAssure() {
      if (assure != null)
      {
         Assure oldAssure;
         for (java.util.Iterator iter = getIteratorAssure(); iter.hasNext();)
         {
            oldAssure = (Assure)iter.next();
            iter.remove();
            oldAssure.setAgence((Agence)null);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<Agent> getAgent() {
      if (agent == null)
         agent = new java.util.HashSet<Agent>();
      return agent;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorAgent() {
      if (agent == null)
         agent = new java.util.HashSet<Agent>();
      return agent.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newAgent */
   public void setAgent(java.util.Collection<Agent> newAgent) {
      removeAllAgent();
      for (java.util.Iterator iter = newAgent.iterator(); iter.hasNext();)
         addAgent((Agent)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newAgent */
   public void addAgent(Agent newAgent) {
      if (newAgent == null)
         return;
      if (this.agent == null)
         this.agent = new java.util.HashSet<Agent>();
      if (!this.agent.contains(newAgent))
      {
         this.agent.add(newAgent);
         newAgent.setAgence(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldAgent */
   public void removeAgent(Agent oldAgent) {
      if (oldAgent == null)
         return;
      if (this.agent != null)
         if (this.agent.contains(oldAgent))
         {
            this.agent.remove(oldAgent);
            oldAgent.setAgence((Agence)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllAgent() {
      if (agent != null)
      {
         Agent oldAgent;
         for (java.util.Iterator iter = getIteratorAgent(); iter.hasNext();)
         {
            oldAgent = (Agent)iter.next();
            iter.remove();
            oldAgent.setAgence((Agence)null);
         }
      }
   }
   /** @pdGenerated default parent getter */
   public Responsable getResponsable() {
      return responsable;
   }
   
   /** @pdGenerated default parent setter
     * @param newResponsable */
   public void setResponsable(Responsable newResponsable) {
      if (this.responsable == null || !this.responsable.equals(newResponsable))
      {
         if (this.responsable != null)
         {
            Responsable oldResponsable = this.responsable;
            this.responsable = null;
            oldResponsable.removeAgence(this);
         }
         if (newResponsable != null)
         {
            this.responsable = newResponsable;
            this.responsable.addAgence(this);
         }
      }
   }

}